/*
 * Copyright 2008 Sun Microsystems, Inc.  All Rights Reserved.
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * This code is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2 only, as
 * published by the Free Software Foundation.  Sun designates this
 * particular file as subject to the "Classpath" exception as provided
 * by Sun in the LICENSE file that accompanied this code.
 *
 * This code is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * version 2 for more details (a copy is included in the LICENSE file that
 * accompanied this code).
 *
 * You should have received a copy of the GNU General Public License version
 * 2 along with this work; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
 * CA 95054 USA or visit www.sun.com if you need additional information or
 * have any questions.
 */
package com.sun.lwuit.impl;

import com.sun.lwuit.Component;
import com.sun.lwuit.Form;
import com.sun.lwuit.Graphics;
import com.sun.lwuit.animations.Animation;
import com.sun.lwuit.geom.Dimension;
import com.sun.lwuit.geom.Rectangle;
import java.io.IOException;
import java.io.InputStream;

/**
 * A decorator to the LWUIT implementation class that allows an implementation to
 * inherit this class while delegating work to a varying underlying class. This is
 * very inefficient and not recommended for performance reasons. However, for debugging
 * and testing of implementations a delegate would be quite powerful
 * 
 * @author Shai Almog
 */
public class LWUITImplementationDecorator extends LWUITImplementation {
    private LWUITImplementation underlying;
    
    /**
     * Creates a decorator implementation with the underlying implementation
     *
     * @param underlying delegated all operations
     */
    public LWUITImplementationDecorator(LWUITImplementation underlying) {
        this.underlying = underlying;
    }
    
    /**
     * @inheritDoc
     */
    public void init(Object m) {
        underlying.init(m);
    }
    
    /**
     * @inheritDoc
     */
    public void playDialogSound(final int type) {
        underlying.playDialogSound(type);
    }    
        
    /**
     * @inheritDoc
     */
    public void vibrate(int duration) {
        underlying.vibrate(duration);
    }
    
    /**
     * @inheritDoc
     */
    public void flashBacklight(int duration) {
        underlying.flashBacklight(duration);
    }
    
    /**
     * @inheritDoc
     */
    public int getDisplayWidth() {
        return underlying.getDisplayWidth();
    }

    /**
     * @inheritDoc
     */
    public int getDisplayHeight() {
        return underlying.getDisplayHeight();
    }
        
    /**
     * @inheritDoc
     */
    public boolean handleEDTException(Throwable err) {
        return underlying.handleEDTException(err);
    }
    
    /**
     * @inheritDoc
     */
    public void editString(Component cmp, int maxSize, int constraint, String text) {
        underlying.editString(cmp, maxSize, constraint, text);
    }
    
    /**
     * @inheritDoc
     */
    public void saveTextEditingState() {
        underlying.saveTextEditingState();
    }
    
    /**
     * @inheritDoc
     */
    public boolean hasPendingPaints() {
        return underlying.hasPendingPaints();
    }

    /**
     * @inheritDoc
     */
    public Object getVideoControl(Object player) {
        return underlying.getVideoControl(player);
    }
    
    /**
     * @inheritDoc
     */
    public int numAlphaLevels(){
        return underlying.numAlphaLevels();
    }

    /**
     * @inheritDoc
     */
    public int numColors() {
        return underlying.numColors();
    }

    /**
     * @inheritDoc
     */
    protected void paintOverlay(Graphics g) {
        underlying.paintOverlay(g);
    }
    
    /**
     * @inheritDoc
     */
    public void paintDirty() {
        underlying.paintDirty();
    }
    
    /**
     * @inheritDoc
     */
    public void flushGraphics(int x, int y, int width, int height) {
        underlying.flushGraphics(x, y, width, height);
    }
    
    /**
     * @inheritDoc
     */
    public void flushGraphics() {
        underlying.flushGraphics();
    }

    /**
     * @inheritDoc
     */
    protected Graphics getLWUITGraphics() {
        return underlying.getLWUITGraphics();
    }
    
    /**
     * @inheritDoc
     */
    public void setLWUITGraphics(Graphics g) {
        underlying.setLWUITGraphics(g);
    }
    
    /**
     * @inheritDoc
     */
    public void setDisplayLock(Object lock) {
        underlying.setDisplayLock(lock);
    }
    
    /**
     * @inheritDoc
     */
    public Object getDisplayLock() {
        return underlying.getDisplayLock();
    }
    
    /**
     * @inheritDoc
     */
    public void repaint(Animation cmp) {
        underlying.repaint(cmp);
    }
    
    /**
     * @inheritDoc
     */
    public void getRGB(Object nativeImage, int[] arr, int offset, int x, int y, int width, int height) {
        underlying.getRGB(nativeImage, arr, offset, x, y, width, height);
    }
    
    /**
     * @inheritDoc
     */
    public Object createImage(int[] rgb, int width, int height) {
        return underlying.createImage(rgb, width, height);
    }

    /**
     * @inheritDoc
     */
    public Object createImage(String path) throws IOException {
        return underlying.createImage(path);
    }

    /**
     * @inheritDoc
     */
    public Object createImage(InputStream i) throws IOException {
        return underlying.createImage(i);
    }

    /**
     * @inheritDoc
     */
    public Object createMutableImage(int width, int height, int fillColor) {
        return underlying.createMutableImage(width, height, fillColor);
    }

    /**
     * @inheritDoc
     */
    public boolean isAlphaMutableImageSupported() {
        return underlying.isAlphaMutableImageSupported();
    }
    
    /**
     * @inheritDoc
     */
    public Object createImage(byte[] bytes, int offset, int len) {
        return underlying.createImage(bytes, offset, len);
    }
    
    /**
     * @inheritDoc
     */
    public int getImageWidth(Object i) {
        return underlying.getImageWidth(i);
    }

    /**
     * @inheritDoc
     */
    public int getImageHeight(Object i) {
        return underlying.getImageHeight(i);
    }
    
    /**
     * @inheritDoc
     */
    public Object scale(Object nativeImage, int width, int height) {
        return underlying.scale(nativeImage, width, height);
    }

    /**
     * @inheritDoc
     */
    public Object rotate(Object image, int degrees) {
        return underlying.rotate(image, degrees);
    }

    /**
     * @inheritDoc
     */
    public int getSoftkeyCount() {
        return underlying.getSoftkeyCount();
    }

    /**
     * @inheritDoc
     */
    public int[] getSoftkeyCode(int index) {
       return underlying.getSoftkeyCode(index);
    }

    /**
     * @inheritDoc
     */
    public int getClearKeyCode() {
        return underlying.getClearKeyCode();
    }

    /**
     * @inheritDoc
     */
    public int getBackspaceKeyCode() {
        return underlying.getBackspaceKeyCode();
    }

    /**
     * @inheritDoc
     */
    public int getBackKeyCode() {
        return underlying.getBackKeyCode();
    }

    /**
     * @inheritDoc
     */
    public int getGameAction(int keyCode) {
        return underlying.getGameAction(keyCode);
    }
    
    /**
     * @inheritDoc
     */
    public int getKeyCode(int gameAction) {
        return underlying.getKeyCode(gameAction);
    }
    
    /**
     * @inheritDoc
     */
    public boolean isTouchDevice() {
        return underlying.isTouchDevice();
    }
    
    /**
     * @inheritDoc
     */
    public void setCurrentForm(Form f) {
        underlying.setCurrentForm(f);
    }
    
    /**
     * @inheritDoc
     */
    public void confirmControlView() {
        underlying.confirmControlView();
    }
    
    /**
     * @inheritDoc
     */
    public Form getCurrentForm() {
        return underlying.getCurrentForm();
    }
    
    /**
     * @inheritDoc
     */
    public boolean isTranslationSupported() {
        return underlying.isTranslationSupported();
    }

    /**
     * @inheritDoc
     */
    public void translate(Object graphics, int x, int y) {
        underlying.translate(graphics, x, y);
    }

    /**
     * @inheritDoc
     */
    public int getTranslateX(Object graphics) {
        return underlying.getTranslateX(graphics);
    }

    /**
     * @inheritDoc
     */
    public int getTranslateY(Object graphics) {
        return underlying.getTranslateY(graphics);
    }

    /**
     * @inheritDoc
     */
    public int getColor(Object graphics) {
        return underlying.getColor(graphics);
    }
    
    /**
     * @inheritDoc
     */
    public void setColor(Object graphics, int RGB) {
        underlying.setColor(graphics, RGB);
    }

    /**
     * @inheritDoc
     */
    public void setAlpha(Object graphics, int alpha) {
        underlying.setAlpha(graphics, alpha);
    }
    
    /**
     * @inheritDoc
     */
    public int getAlpha(Object graphics) {
        return underlying.getAlpha(graphics);
    }

    /**
     * @inheritDoc
     */
    public boolean isAlphaGlobal() {
        return underlying.isAlphaGlobal();
    }
    
    /**
     * @inheritDoc
     */
    public void setNativeFont(Object graphics, Object font) {
        underlying.setNativeFont(graphics, font);
    }

    /**
     * @inheritDoc
     */
    public Rectangle getClipRect(Object graphics) {
        return underlying.getClipRect(graphics);
    }

    /**
     * @inheritDoc
     */
    public int getClipX(Object graphics) {
        return underlying.getClipX(graphics);
    }

    /**
     * @inheritDoc
     */
    public int getClipY(Object graphics) {
        return underlying.getClipY(graphics);
    }

    /**
     * @inheritDoc
     */
    public int getClipWidth(Object graphics) {
        return underlying.getClipWidth(graphics);
    }

    /**
     * @inheritDoc
     */
    public int getClipHeight(Object graphics) {
        return underlying.getClipHeight(graphics);
    }
    
    /**
     * @inheritDoc
     */
    public void setClipRect(Object graphics, Rectangle rect) {
        underlying.setClipRect(graphics, rect);
    }

    /**
     * @inheritDoc
     */
    public void setClip(Object graphics, int x, int y, int width, int height) {
        underlying.setClip(graphics, x, y, width, height);
    }

    /**
     * @inheritDoc
     */
    public void clipRect(Object graphics, Rectangle rect) {
        underlying.clipRect(graphics, rect);
    }
    
    /**
     * @inheritDoc
     */
    public void clipRect(Object graphics, int x, int y, int width, int height) {
        underlying.clipRect(graphics, x, y, width, height);
    }

    /**
     * @inheritDoc
     */
    public void drawLine(Object graphics, int x1, int y1, int x2, int y2) {
        underlying.drawLine(graphics, x1, y1, x2, y2);
    }

    /**
     * @inheritDoc
     */
    public void fillRect(Object graphics, int x, int y, int width, int height) {
        underlying.fillRect(graphics, x, y, width, height);
    }

    /**
     * @inheritDoc
     */
    public void drawRect(Object graphics, int x, int y, int width, int height) {
        underlying.drawRect(graphics, x, y, width, height);
    }

    /**
     * @inheritDoc
     */
    public void drawRoundRect(Object graphics, int x, int y, int width, int height, int arcWidth, int arcHeight) {
        underlying.drawRoundRect(graphics, x, y, width, height, arcWidth, arcHeight);
    }

    /**
     * @inheritDoc
     */
    public void fillRoundRect(Object graphics, int x, int y, int width, int height, int arcWidth, int arcHeight) {
        underlying.fillRoundRect(graphics, x, y, width, height, arcWidth, arcHeight);
    }

    /**
     * @inheritDoc
     */
    public void fillArc(Object graphics, int x, int y, int width, int height, int startAngle, int arcAngle) {
        underlying.fillArc(graphics, x, y, width, height, startAngle, arcAngle);
    }

    /**
     * @inheritDoc
     */
    public void drawArc(Object graphics, int x, int y, int width, int height, int startAngle, int arcAngle) {
        underlying.drawArc(graphics, x, y, width, height, startAngle, arcAngle);
    }

    /**
     * @inheritDoc
     */
    public void drawString(Object graphics, String str, int x, int y) {
        underlying.drawString(graphics, str, x, y);
    }

    /**
     * @inheritDoc
     */
    public void drawImage(Object graphics, Object img, int x, int y) {
        underlying.drawImage(graphics, img, x, y);
    }

    /**
     * @inheritDoc
     */
    public void drawImageRotated(Object graphics, Object img, int x, int y, int degrees) {
        underlying.drawImageRotated(graphics, img, x, y, degrees);
    }
    
    /**
     * @inheritDoc
     */
    public boolean isRotationDrawingSupported() {
        return underlying.isRotationDrawingSupported();
    }

    /**
     * @inheritDoc
     */
    public void fillTriangle(Object graphics, int x1, int y1, int x2, int y2, int x3, int y3) {
        underlying.fillTriangle(graphics, x1, y1, x2, y2, x3, y3);
    }

    /**
     * @inheritDoc
     */
    public void drawRGB(Object graphics, int[] rgbData, int offset, int x, int y, int w, int h, boolean processAlpha) {
        underlying.drawRGB(graphics, rgbData, offset, x, y, w, h, processAlpha);
    }
    
    /**
     * @inheritDoc
     */
    public Object getNativeGraphics() {
        return underlying.getNativeGraphics();
    }

    /**
     * @inheritDoc
     */
    public Object getNativeGraphics(Object image) {
        return underlying.getNativeGraphics(image);
    }
    
    
    /**
     * @inheritDoc
     */
    public int charsWidth(Object nativeFont, char[] ch, int offset, int length) {
        return underlying.charsWidth(nativeFont, ch, offset, length);
    }
    
    /**
     * @inheritDoc
     */
    public int stringWidth(Object nativeFont, String str) {
        return underlying.stringWidth(nativeFont, str);
    }
    
    /**
     * @inheritDoc
     */
    public int charWidth(Object nativeFont, char ch) {
        return underlying.charWidth(nativeFont, ch);
    }
    
    /**
     * @inheritDoc
     */
    public int getHeight(Object nativeFont) {
        return underlying.getHeight(nativeFont);
    }
    
    /**
     * @inheritDoc
     */
    public Object getDefaultFont() {
        return underlying.getDefaultFont();
    }

    /**
     * @inheritDoc
     */
    public int getFace(Object nativeFont) {
        return underlying.getFace(nativeFont);
    }
    
    /**
     * @inheritDoc
     */
    public int getSize(Object nativeFont) {
        return underlying.getSize(nativeFont);
    }

    /**
     * @inheritDoc
     */
    public int getStyle(Object nativeFont) {
        return underlying.getStyle(nativeFont);
    }

    /**
     * @inheritDoc
     */
    public Object createFont(int face, int style, int size) {
        return underlying.createFont(face, style, size);
    }
            
    /**
     * @inheritDoc
     */
    protected void keyPressed(final int keyCode){
        underlying.keyPressed(keyCode);
    }

    /**
     * @inheritDoc
     */
    protected  void keyReleased(final int keyCode){
        underlying.keyReleased(keyCode);
    }
    
    /**
     * @inheritDoc
     */
    protected  void pointerDragged(final int x, final int y){
        underlying.pointerDragged(x, y);
    }
    
    /**
     * @inheritDoc
     */
    protected  void pointerPressed(final int x,final int y){
        underlying.pointerPressed(x, y);
    }
    
    /**
     * @inheritDoc
     */
    protected  void pointerReleased(final int x,final int y){
        underlying.pointerReleased(x, y);
    }
    
    /**
     * @inheritDoc
     */
    protected void sizeChanged(int w, int h){
        underlying.sizeChanged(w, h);
    }

    /**
     * @inheritDoc
     */
    public void fillRadialGradient(Object graphics, int startColor, int endColor, int x, int y, int width, int height) {
        underlying.fillRadialGradient(graphics, startColor, endColor, x, y, width, height);
    }

    /**
     * @inheritDoc
     */
    public void fillLinearGradient(Object graphics, int startColor, int endColor, int x, int y, int width, int height, boolean horizontal) {
        underlying.fillLinearGradient(graphics, startColor, endColor, x, y, width, height, horizontal);
    }

    /**
     * @inheritDoc
     */
    public void fillPolygon(Object graphics, int[] xPoints, int[] yPoints, int nPoints) {
        underlying.fillPolygon(graphics, xPoints, yPoints, nPoints);
    }

    /**
     * @inheritDoc
     */
    public void drawPolygon(Object graphics, int[] xPoints, int[] yPoints, int nPoints) {
        underlying.drawPolygon(graphics, xPoints, yPoints, nPoints);
    }
}
